<?php

class Schedule extends Eloquent {
	protected $guarded = array();

	public static $rules = array(
		'event_name'=> 'required',
		'event_type'=> 'required',
		'start_time'=> 'required',
		'end_time'	=> 'required',
		'description'	=> '',
		'fee_schedule	'=>''
	);

	public function registered($id)
	{
		$results = DB::table('enroll_events')
					->where('event_id', '=', $id)
					->where('user_id', '=', Auth::user()->id)
					->count();
		return $results;
	}

	public function registered_list()
	{
		$results = DB::table('schedules')
					->join('enroll_events', 'enroll_events.event_id', '=', 'schedules.id')
					->select('enroll_events.id', 'schedules.event_type', 'schedules.start_time','schedules.end_time')
					->where('enroll_events.user_id', '=', Auth::user()->id)
					->get();
		return $results;
	}
}
